package com.cnswhy.cloud.server.common.entity.enumeration;

import com.cnswhy.cloud.common.core.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 系统配置表
 * </p>
 *
 * @author cnswhy
 * @date 2020-10-16
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ConfigKey", description = "配置类型 #ConfigKey{file_ftp_ip:fTP文件IP;-枚举")
public enum ConfigKey implements BaseEnum {

    /**
     * FILE_FTP_IP="fTP文件IP"
     */
    file_ftp_ip("fTP文件IP"),
    file_ftp_port("fTP端口"),
    file_ftp_user("fTP用户名"),
    file_ftp_pwd("fTP密码"),
    ftp_path_image("fTP路径"),
    ftp_path_prefix("fTP路径前缀"),
    sys_password_overtime("密码超时时间"),
    websit_url("后台地址"),
    alipay_notify_url("支付宝通知地址"),
    wx_notify_url("微信支付回调地址"),
    alipay_syn_url("支付宝前端同步跳转地址"),
    spell_start_end_time("拼团时间"),
    spell_charge_money("拼购券充值金额"),
    sd_notify_url("杉德支付回调地址"),
    balance_withdraw_service("余额提现手续费"),
    alipay_auth_notify_url("支付宝预授权回调地址"),
    buy_back_price("拼团回购商品折扣"),
    contribution_share_rate("个人贡献池分红比例"),
    spell_share_rate("团队拼团池分红比例"),
    platform_share_rate("系统平台分红池"),
    andriod_app_version("安卓最新版本号"),
    andriod_app_download("安卓下载链接"),
    share_profit_auto("系统自动发放收益"),
    push_user_money("推荐用户分享红包，拼团价格百分比"),
    customer_service_url("客服链接地址"),
    /**
     * wx_notify_url
     * alipay_syn_url
     * spell_start_end_time
     * spell_charge_money
     * sd_notify_url
     * balance_withdraw_service
     * alipay_auth_notify_url
     * buy_back_price
     * contribution_share_rate
     * spell_share_rate
     * platform_share_rate
     * andriod_app_version
     * andriod_app_download
     * share_profit_auto
     * push_user_money
     * customer_service_url
     */
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 跟就当前枚举的name匹配
     */
    public static ConfigKey match(String val, ConfigKey def) {
        return Stream.of(values()).parallel().filter((item) -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static ConfigKey get(String val) {
        return match(val, null);
    }

    public boolean eq(ConfigKey val) {
        return val == null ? false : eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "FILE_FTP_IP", example = "FILE_FTP_IP")
    public String getCode() {
        return this.name();
    }

}
